package com.woniuxy.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {

    /**
     * String转换成Date   2010/10/10
     */
    public static Date stringToDate(String str,String pattern){
        DateFormat df = new SimpleDateFormat(pattern);
        try {
            return df.parse(str);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }

    public static Date stringToDate(String str){
        return stringToDate(str,"yyyy-MM-dd");
    }

    public static Date addOneDay(Date date){
        date.setTime(date.getTime()+(24*60*60*1000-1));
        return date;
    }
}
